package com.twu.biblioteca;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class BibliotecaApp {

    public static void main(String[] args) {
        List<Book> bookList = new ArrayList<Book>();
        Book book = new Book("Java", "AA", "2001");
        Book book1 = new Book("C++", "BB", "2001");
        bookList.add(book);
        bookList.add(book1);

        Biblioteca biblioteca = new Biblioteca(bookList);

        System.out.println(biblioteca.getInto());
        System.out.println("please choose the menu by the number such as 1:");
        System.out.println(biblioteca.getMenuDetails());

        Scanner scanner = new Scanner(System.in);
        String name;
        while (true) {
            int number = scanner.nextInt();
            String option = biblioteca.chooseOption(number);
            if (option.equals("List Books")) {
                System.out.println("Name  Author  YearPublished");
                System.out.println(biblioteca.getBooksDetails());
            } else if (option.equals("Checkout Book")) {
                System.out.println("Please input the checkouted book name:");
                name = scanner.next();
                System.out.println(biblioteca.checkOutForBook(name));
            } else if (option.equals("Return Book")) {
                System.out.println("Please input the returned book name:");
                name = scanner.next();
                System.out.println(biblioteca.returnedBook(name));
            } else if (option.equals("Quit")) {
                System.out.println("See you later!");
                break;
            } else {
                System.out.println(option + "Please input again:");
            }
        }
    }
}
